package Text1;

import java.util.*;

public class Main {
    public static int N = 510, M = 10010, n, m, k, max = 0x3f3f3f3f;
    public static int[] dist = new int[N];//从一号点到n号点的距离
    public static int[] back = new int[N];//备份数组从一号点到n号点的距离
    public static edg[] edgs = new edg[M];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        k = in.nextInt();
        for (int i = 0; i < m; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            int w = in.nextInt();
            edgs[i] = new edg(a, b, w);
        }
        Arrays.fill(dist, max);
        dist[1] = 0;
        bellman_ford();
    }

    private static void bellman_ford() {
        for (int i = 0; i < k; i++) {
            back = Arrays.copyOf(dist, n+1);
            for (int j = 0; j < m; j++) {
                int a = edgs[j].a;
                int b = edgs[j].b;
                int w = edgs[j].w;
                if (dist[b] > back[a] + w) {
                    dist[b] = back[a] + w;
                }
            }
        }
        if (dist[n] > max / 2) System.out.println("impossible");
        else System.out.println(dist[n]);
    }
}

class edg {
    int a, b, w;

    public edg(int a, int b, int w) {
        this.a = a;
        this.b = b;
        this.w = w;
    }
}